<?php
/**
 * @filesource:					BuryAction.class.php
 * @desc:						落葬人管理模块
 * 
 * @author:						shenyaqing
 * @copyright:					hou.yining@gmail.com
 * @date:						2011-04-20
 */
class BuryAction extends CommonDeadAction{
	public function index(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('bury_manage'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/add', 'title' => L('add_bury')),
		);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
		$model = D ('dead');
		$id = $_REQUEST['id'];
		$map = "type_id='$id'";
		if (! empty ( $model )) {
			$this->_list ( $model, $map );
		}
		$this->display ();
		
	}
	public function add(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('bury_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/add/', 'title' => L('add_bury'), 'sort' => C('CRUMB_LAST')),
		);
		
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index/id/2', 'title' => L('list_bury')),
			);
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
		$obj = D('graveyard');
		$result = $obj->where()->select();
		$this->assign('result',$result);
		
		$o = D('general_customer');
		$rr = $o->where("type_id=4")->select();
		$name = $_REQUEST['name'];
		$id = $_REQUEST['id'];
		$this->assign('name',$name);
		$this->assign('id',$id);
		$this->assign('rr',$rr);
		
		$omit = D('region');
		$province = $omit->where("level=1")->select();
		$this->assign('province',$province);
		parent::add();
	}
	public function edit(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('bury_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/edit/id/' . $_REQUEST['id'], 'title' => L('edit_bury'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index/id/2', 'title' => L('list_bury')),
			);
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		
		$model = M ( 'dead' );
		$id = $_REQUEST [$model->getPk ()];
		$vo = $model->table('GMS_dead d,GMS_general_customer g')->where("d.charge_person_id=g.id and d.id='$id'")->field('d.*,g.name charge_person_name')->select();

		$this->assign ( 'list', $vo );
		
		$obj =  D( 'general_customer' );
		$result = $obj->where('type_id=4')->select();
		$this->assign ( 'rr', $result );
		
		$mo =  D( 'graveyard' );
		$res = $mo->select();
		$this->assign ( 'result', $res );
		
		$omit = D('region');
		$province = $omit->where("level=1")->select();
		$this->assign('province',$province);
		$this->display ();
	}
	public function all_delete(){
    	parent::all_delete();
		echo "<script>alert('已全部删除！');window.location.href('".ROOT_PATH."Bury/index/id/2');</script>";
    }
	public function search(){
		if(!empty($_POST['name'])){
			$where['name'] = $_POST['name'];
		}
		if(!empty($_POST['age'])){
			$where['age'] = $_POST['age'];
		}
		if(!empty($_POST['address'])){
			$where['address'] = $_POST['address'];
		}
		$dead = D('dead');
		$a = $dead->where($where)->select();
		$this->assign('list',$a);
		$this->display('index');
		
		/*$model = M ( 'dead' );
		$where = $_POST['search'];
		$result = $model->where("name='$where'")->select(); 
		$this->assign('list',$result);
		$this->display('index');*/
	}
	public function selectEntre(){
		$this->display();
	}
	public function searEntre(){
		if(!empty($_POST['name'])){
			$where['name'] = $_POST['name'];
		}
		if(!empty($_POST['age'])){
			$where['age'] = $_POST['age'];
		}
		if(!empty($_POST['address'])){
			$where['address'] = $_POST['address'];
		}
		$obj = D('general_customer');
		$a = $obj->where($where)->select();
		$this->assign('vo',$a);
		$this->display('selectEntre');
	}

	
}
?>